package sketchpad.gui.drawinggraph;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import sketchpad.constant.CHNName;
import sketchpad.constant.Geometry;
import sketchpad.constant.SketchPadColor;
import sketchpad.gui.drawinggraph.node.Node;

import java.io.Serializable;

public class Circle extends DrawItem implements Serializable {

    public Circle(int id, Node node){
        super(id, node);
        setGeometryClass(Geometry.CIRCLE);
        setLabel(CHNName.CIRCLE);
    }

    @Override
    public void draw(Node mouseNode, GraphicsContext gc){
        double x3 = getLeftUpNode().x;
        double y3 = getLeftUpNode().y;
        double x4 = mouseNode.x;
        double y4 = mouseNode.y;
        setRightDownNode(new Node(x4,y4));
        if (!isSelect())gc.setStroke(Color.valueOf(SketchPadColor.COLOR_CIRCLE));
        gc.strokeOval(Math.min(x3,x4),y3<y4?y3:y4,Math.abs(x3-x4),Math.abs(y3-y4));
    }
}
